#include <Mp3EncoderFactoryI.h>
#include <Mp3EncoderI.h>
#include <Ice/Ice.h>

using namespace std;
using namespace Ripper;

Mp3EncoderPrx
Mp3EncoderFactoryI::createEncoder(::Ice::Int channels,
				  ::Ice::Int rate,
				  const ::Ice::Current& current)
{
  if (_proxy)
    {
      try
	{
	  _proxy->flush();
	}
      catch (const Ice::ObjectNotExistException&)
	{	  
	}
      _proxy = 0;
    }
  Ice::ObjectPtr encoder = new Mp3EncoderI(channels, rate);
  _proxy = Mp3EncoderPrx::uncheckedCast(current.adapter->addWithUUID(encoder));
  return _proxy;
}
